package com.cskaoyan.advice;

import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
import org.springframework.stereotype.Component;

@Component
public class CustomAdvice implements MethodInterceptor {
    //这个invoke就是通知方法 👉 就类似于InvocationHandler的invoke方法
    //代理对象去执行方法就是执行MethodInterceptor的invoke方法
    @Override
    public Object invoke(MethodInvocation methodInvocation) throws Throwable {
        System.out.println("学姐好");
        //1、委托类方法的执行
        Object proceed = methodInvocation.proceed();
        //2、增强
        System.out.println("学姐再见");
        return proceed;
    }
}
